﻿@model Article
<form class="form-horizontal uiform" method="post"
      data-modal="true"
      data-table=".uitable"
      data-error-el=".alert-danger"
      data-on-submit-success="fx.mtfSuccess"
      action="@Url.Action("Save")">
    <div class="modal-header">
        <button class="close" data-dismiss="modal" type="button" aria-label="Close">
            <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">@Html.EditStatus("文章信息")</h4>
    </div>
    <div class="modal-body">
        @Html.AntiForgeryToken()
        @Html.MarkCreate()
        @Html.HiddenFor(p => p.Id)
        <div class="alert alert-danger fxhide"></div>
        <div class="form-group">
            <label class="control-label col-md-1" style="width: 100px;">
                <span class="required"> * </span>
                标题：
            </label>
            <div class="col-md-11" style="width:90%">
                <input class="form-control" name="@nameof(Model.Subject)" value="@Model.Subject"
                       data-validate="required: true,maxlength: 200"
                       data-validate-message="required:'请输入标题'"
                       type="text" autocomplete="off" />
            </div>
            
        </div>
        <div class="form-group">
            <label class="control-label col-md-1" style="width: 100px;">
                <span class="required"> * </span>
                分类：
            </label>
            <div class="col-md-11" style="width:40%">
                @*<select class="form-control uiselect" name="@nameof(Model.CategoryId)"
                        data-text-field="CategoryName" data-allow-clear="false">
                    <option></option>
                    @Html.ArticleCategoryOption(Model.CategoryId)
                </select>*@
                <div id="category" type="selectTree" class="ui-select" style="width:90%"></div>
                <input type="hidden" name="@nameof(Model.CategoryId)" id="@nameof(Model.CategoryId)" value="@Model.CategoryId" />
                <input type="hidden" name="@nameof(Model.CategoryName)" id="@nameof(Model.CategoryName)" value="@Model.CategoryName" />
            </div>
            <label class="control-label col-md-1" style="width: 100px;">
                <span class="required"> * </span>
                状态：
            </label>
            <div class="col-md-11" style="width: 40%">
                <div class="input-group">
                    <label class="checkbox-inline" style="padding-left: 0">
                        <input class="uicheck"
                               name="@nameof(Model.Status)"
                               value="true" type="checkbox"
                               @Html.IsChecked(Model.Status)/>
                        <span>自动审核</span>
                    </label>
                    <label class="checkbox-inline">
                        <input class="uicheck"
                               name="@nameof(Model.IsSlide)" value="true"
                               type="checkbox" @Html.IsChecked(Model.IsSlide) />
                        <span>幻灯</span>
                    </label>
                </div>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-md-1" style="width: 100px;">
                <span class="required"> * </span>
                内容：
            </label>
            <div class="col-md-11" style="width:90%">
                <textarea class="form-control" id="Contents" name="@nameof(Model.Contents)"
                          data-validate="required: true" data-validate-message="required:'请输入消息内容'"
                          style="width:100%;height:600px">
                    @Model.Contents
                </textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-1" style="width: 100px;">
                图片：
            </label>
            <div class="col-md-11" style="width:90%">
                <input name="attachment" type="file" class="uifileupload" 
                       accept=".png,.jpg">
            </div>
        </div>

        @if (Model.PhotoUrl.IsNotEmpty())
        {
            <div class="form-group">
                <label class="control-label col-md-1" style="width: 100px;">
                     
                </label>
                <div class="col-md-11" style="width:90%">
                    <img src="@Url.Content(Model.PhotoUrl)" alt="" style="width:300px;height:300px;" />
                </div>
            </div>
        }


    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="submit">
            <i class="fa fa-save"></i> 保存
        </button>
        <button class="btn btn-default" type="button" data-dismiss="modal">
            <i class="fa fa-sign-in"></i> 关闭
        </button>
    </div>
</form>
 
<script>
    initKindEditor('#Contents');

    $("#category").ComboBoxTree({
        url: "@Url.Action("GetTreeJson")",
        description: "请选择分类",
        height: "200px",
        allowSearch: true,
    }).bind("change", function () {
        var value = $(this).attr('data-value');
        var text = $(this).attr('data-text');
        $('#CategoryId').val(value);
        $('#CategoryName').val(text);
    });

    $("#category").ComboBoxTreeSetValue('@Model.CategoryId');

</script>